Topic:
The
Friendship Between a Dog and His Owner
Points: 25
Instructor: Dana Steil
Friend Classes
Member Initialization List
You will be creating two classes, one for a dog another for a dog’s owner. Every CdogsOwner has a dog as a data member. A CDog can also be created on its own.
1. Use complier directives to avoid redefinition problems with the CDog class.
a) void PutLeashOn(); Sets the OnLeash property of its dog to true;
b)
void TakeLeashOff(); Sets the OnLeash property of its dog to
false; and causes the dog to roll over.
c)
void PutLeashOn(CDog& Dog); Causes the strange dog to
bark and byte.
d)
void TakeLeashOff(CDog& Dog); Calls the Steal Dog
utility function.
a) Do not change any properties of the ower or the owner’s dog.
b) Inform the user that an owner (by name) is stealing a dog (by name).
c) Ask the user for a new name for the stolen dog and change its name.
Write your own!!
#include "Dog.h"
#include "Owner.h"
#include <iostream>
using std::cout;
using std::endl;
void main()
{
CDogOwner Bob("Bob", "Sammy");
CDog Rover("Rover");
CDog Duke("Duke");
Rover.Bark();
Rover.Scratch();
Bob.PutLeashOn();
Bob.TakeLeashOff();
Bob.PutLeashOn(Rover);
Bob.TakeLeashOff(Duke);
Duke.Bark();
}
results:
The dog Rover is barking.
The dog Rover is scratching.
The dog Sammy is rolling over.
The dog Rover is barking.
The dog Rover just bit you.
Bob is stealing Duke
What whould you like your stolen dog's name to be:
Bell
The dog Bell is barking.
Press any key to continue